import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../pages/goodpage/goodpage.dart';

class GoodsCard extends StatefulWidget {
  GoodsCard({Key key, this.name, this.price, this.imgurl1, this.id,this.tagname})
      : super(key: key);

  String name;
  String tagname;
  double price;
  String imgurl1;
  int id;

  @override
  _GoodsCardState createState() => _GoodsCardState();
}

class _GoodsCardState extends State<GoodsCard> {
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.only(left:8.0,right:8),
      child: InkWell(
        onTap: () {
          Navigator.push(context, MaterialPageRoute(builder: (context)=>GoodPage(id: widget.id,url1: widget.imgurl1,tagname: widget.tagname,)));
        },
        child: Container(
          decoration: new BoxDecoration(
            color: Color.fromRGBO(210, 234, 244, 1),
            //设置四周圆角 角度
            borderRadius: BorderRadius.all(Radius.circular(20.0)),
          ),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Hero(
                tag: widget.tagname,
                child: Image.network(
                  widget.imgurl1,
                  width: 100,
                ),
              ),
              Padding(
                padding: const EdgeInsets.all(5.0),
                child: Text(
                  widget.name,
                  style: TextStyle(
                      fontSize: 14,
                      fontWeight: FontWeight.bold,
                      color: Color.fromRGBO(25, 31, 43, 0.8)),
                ),
              ),
              Text(
                '￥' + widget.price.toString(),
                style: TextStyle(
                    fontSize: 20,
                    fontWeight: FontWeight.bold,
                    color: Color.fromRGBO(25, 31, 43, 0.8)),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
